Technical Q&As
QD 25 - Problems with DiffRgn (15-Sept-95)
Q I'm having a bit of a problem with DiffRgn. I start out
with a "wide open" rectangular region (-32767, -32767, 32767, 32767) and then
use DiffRgn to subtract a group of smaller rectangles from it. When I'm done,
the bounding box of the region isn't what it should be. Any idea what's
happening?
A What you need to do is create your clipping region so that it's not quite
wide open (bottom and right coordinates of 32766 will work). If you do this,
all your DiffRgn calculations will work fine.
While this isn't explicitly documented anywhere, it does seem to be a quirk in
the way regions work. Due to the internal storage format of regions, the number
0x7FFF (32767) causes problems if it appears as a point inside a region. 0x7FFF
is used as a flag in the internal region data structure to signify a "barrier."
When this flag is used as a data point in a nonrectangular region, region
parsing becomes completely screwed up.
QuickDraw tries to catch the creation of regions that will be poorly formed and
turn them into properly formed (but slightly incorrect) regions, but it isn't
100% successful.
Technical Q&As
Previous Question | Contents | Next Question